<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }

        div:first-child{
            width: 350px;
            height: 250px;
            position: relative;
            margin: 0 auto;
            margin-top: 50px;
            box-sizing: border-box;
        }
        #div1 >ul > li{
            position: absolute;
            list-style: none;
            /* z-index: 1; */
        }
        ul>li>img{
            width: 350px;
            height: 250px;
        }
        #div1>ul:nth-child(2)>li{
            /* position: static; */
            position: relative;
            top: 235px;
            width: 10px;
            height: 10px;
            border-radius: 50%;
            background-color: chartreuse;
            margin-right: 5px;
            list-style: none;
            z-index: 5;
            float: left;
            
        }
        #div1 > ul:nth-child(2)>li:hover
        {
            background-clip: content-box;
            background-color: gray;
            border: 2px solid #E0DEDA;
        }
        
    </style>
</head>
<body>
    <div id="div1">
        <ul>
            <li><img src="a1.jpg" alt=""></li>
            <li><img src="a2.webp"></li>
            <li><img src="a6fbeae63ec0d46c.jpg.webp"></li>
            <li><img src="beab09dd3580d957.jpg.webp"></li>
            <li><img src="fdff58457adbef3e.jpg.webp"></li>
        </ul>
        <ul>
            <li></li>
            <li></li>
            <li></li>
            <li></li>
            <li></li>
        </ul>
    </div>
</body>
<script>
    // var ss=document.querySelector("#div1 ul:nth-child(1)> li:nth-child(3)");
    // ss.style.cssText="z-index:"+4;
    
    var allss=document.querySelectorAll("#div1 ul:nth-child(2)> li");
    var allimg=document.querySelectorAll("#div1 ul:nth-child(1)> li");
    // allimg[2].style.cssText="z-index:"+4;

    for(var i=0;i<allss.length;i++)
    {
        allss[i].onmouseover=function()
        {
            for(var i=0;i<allss.length;i++)
            {
                allimg[i].style.cssText="z-index:"+2;
            }
            var x;
            for(var j=0;j<allss.length;j++)
            {
                if(allss[j]==this)
                {
                    x=j;
                    break;
                }
            }
            allimg[x].style.cssText="z-index:"+4;
        }
        // allss[i].onmouseout=function()
        // {
        //     var x;
        //     for(var j=0;j<allss.length;j++)
        //     {
        //         if(allss[j]==this)
        //         {
        //             x=j;
        //             break;
        //         }
        //     }
        //     allimg[x].style.cssText="z-index:"+2;
        // }
    }
</script>
</html>